package com.hjm.project.frozenAgent.service.impl;

import java.util.List;

import com.hjm.common.exception.BusinessException;
import org.springframework.stereotype.Service;
import com.hjm.project.frozenAgent.mapper.FrozenAgentMapper;
import com.hjm.project.frozenAgent.domain.FrozenAgent;
import com.hjm.project.frozenAgent.service.IFrozenAgentService;
import com.hjm.common.utils.text.Convert;

import javax.annotation.Resource;

/**
 * 代理商冻结Service业务层处理
 * 
 * @author maker-platform
 * @date 2021-04-23
 */
@Service
public class FrozenAgentServiceImpl implements IFrozenAgentService 
{
    @Resource
    private FrozenAgentMapper frozenAgentMapper;

    /**
     * 查询代理商冻结
     * 
     * @param agentNum 代理商冻结ID
     * @return 代理商冻结
     */
    @Override
    public FrozenAgent selectFrozenAgentById(String agentNum)
    {
        return frozenAgentMapper.selectFrozenAgentById(agentNum);
    }

    /**
     * 查询代理商冻结列表
     * 
     * @param frozenAgent 代理商冻结
     * @return 代理商冻结
     */
    @Override
    public List<FrozenAgent> selectFrozenAgentList(FrozenAgent frozenAgent)
    {
        return frozenAgentMapper.selectFrozenAgentList(frozenAgent);
    }

    /**
     * 新增代理商冻结
     * 
     * @param frozenAgent 代理商冻结
     * @return 结果
     */
    @Override
    public int insertFrozenAgent(FrozenAgent frozenAgent) {
        FrozenAgent frozenAgent1 = frozenAgentMapper.selectFrozenAgentById(frozenAgent.getAgentNum());
        if (frozenAgent1 != null) {
            throw new BusinessException("当前代理账户已冻结");
        }
        return frozenAgentMapper.insertFrozenAgent(frozenAgent);
    }

    /**
     * 修改代理商冻结
     * 
     * @param frozenAgent 代理商冻结
     * @return 结果
     */
    @Override
    public int updateFrozenAgent(FrozenAgent frozenAgent)
    {
        return frozenAgentMapper.updateFrozenAgent(frozenAgent);
    }

    /**
     * 删除代理商冻结对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteFrozenAgentByIds(String ids)
    {
        return frozenAgentMapper.deleteFrozenAgentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除代理商冻结信息
     * 
     * @param agentNum 代理商冻结ID
     * @return 结果
     */
    @Override
    public int deleteFrozenAgentById(String agentNum)
    {
        return frozenAgentMapper.deleteFrozenAgentById(agentNum);
    }
}
